<?php

	require_once("Enzyme.php");

	class AddEnzymeController{

		var $client;
		var $name;
		var $origin;
		var $date;
		var $flag;

		function sendData(){
			$this->client = $_REQUEST['client'];
			$this->name = $_REQUEST['name'];
			$this->origin = $_REQUEST['origin'];
			$this->date = $_REQUEST['date'];
			$this->flag = $_REQUEST['flag'];
		}		
		function retrieveEnzymes(){
			$enzyme = new Enzyme;
			$enzyme->retrieve();
		}

	}
		
	$addEnzymeController = new AddEnzymeController;
	$addEnzymeController->sendData();
	
	if($addEnzymeController->flag=="retrieveAllEnzymes"){
		$addEnzymeController->retrieveEnzymes();
	}
	
	elseif($addEnzymeController->flag=="submit"){
			echo "	<script>";
			
			echo "		client = \"".$addEnzymeController->client."\";";
			echo "		name = \"".$addEnzymeController->name."\";";
			echo "		origin = \"".$addEnzymeController->origin."\";";
			echo "		date = \"".$addEnzymeController->date."\";";
			echo "		flag = \"add\";";
			
			echo "		from = \"confirm\";";
			
			echo "		$.post('viewEnzymeInfo.php',{";		
			echo "			client: client,";
			echo "			name: name,";
			echo "			origin: origin,";
			echo "			date: date,";
			echo "			flag: flag,";
			
			echo "			from:from";
			echo "			},function(data){";
			echo "				$('#view').html(data);";
			echo "			}";
			echo "		);";
			echo "	</script>";
	}
	elseif($addEnzymeController->flag=="Edit"){
		echo "Name<br /><input type='text' name='company' value=\"".$addEnzymeController->name."\" id='company' /><br />";
		echo "Place of Origin<br /><input type='text' name='address' value=\"".$addEnzymeController->origin."\" id='address' /><br />";
		echo "Test Procedure<br /><input type='text' name='cellNo' value=\"".$addEnzymeController->test."\" id='cellNo' /><br />";
		echo "Date Submitted<br /><input type='text' name='telNo' value=\"".$addEnzymeController->date."\" id='telNo' /><br />";
		echo "<input type='button' value='Submit' id='buttonSubmit' onclick=\"submitClientData('submit');return false;\" />";	
	}
	elseif($addEnzymeController->flag=="confirm"){
		$enzyme = new Enzyme();
		$enzyme->sendEnzymeDetails("","",$addEnzymeController->client, $addEnzymeController->name, $addEnzymeController->origin, $addEnzymeController->date);
		$enzyme->add();
	}

?>